                                                                                                                                                                                                                                     <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../css/bootstrap.min.css">
    <link rel="stylesheet" href="../plugins/fontawesome-free/css/all.min.css">
    <link rel="stylesheet" href="../plugins/layui/css/layui.css">
    <script src="../plugins/jquery/jquery.min.js"></script>
    <script src="../js/bootstrap.min.js"></script>
    <script src="../plugins/layui/layui.js"></script>
</head>
<body>

<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <center><h4 class="modal-title" id="myModalLabel">选择员工进行委派</h4></center>
            </div>
            <div class="modal-body"><center><select id="sel" style="width: 300px  ;  border-radius:8px; height :30px;text-align: center;background-color: #2e93ff">

            </select></center></div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" id="wpbut" onclick="wpcl()"> 委派</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->x
</div>
<center>
<table class="table table-striped" style="width: 70%" id="tab">
  <tr>

        <td>维修编号</td>
        <td>备注</td>
      <td>申请人姓名</td>
        <td>联系电话</td>
        <td>申请时间</td>
        <td>操作/委派</td>
  </tr>
</table>
</center>
<script>

    /**
     * 刷新界面
     */
    function  ff(){
        window.location.href="appoint.html"
    }


    /**
     * 获取emp的enameo
     */
    $.ajax({
        url:"getename",
        type: "post",
        success:function (data){

            for (let i=0;i<data.length;i++){
             let op=$("<option>")
             op.html(data[i])

             $("#sel").append(op)
            }
        }

    })

    /**
     * 手动开启模态框
     * 获取维修编号
     */
    let bh;
    let lxdh;
    function wp(wxbh,lxdh){
        $('#myModal').modal('show');

        bh=wxbh
        lxdh=lxdh
    }

    /**
     * 委派
     * 员工进行处理
     */
    function  wpcl(){
        let sel=$("#sel").val()

        $.ajax({
            url:"ddwp",
            type:"post",
            data:{"wpname":sel,"bh":bh,"lxdh":lxdh},
            success:function (data){
                if(data){
                    $.ajax({
                        url:"xiugaimzt",
                        type:"post",
                        data:{"bh":bh},
                        success:function (data){
                            if(data){
                                layer.msg('修改状态成功', {icon: 6});
                                setTimeout("ff()","1100");

                            }else{
                                layer.msg('修改状态失败', {icon: 2});
                                setTimeout("ff()","1100");

                            }
                        }

                    })

                    layer.msg('委派成功', {icon: 6});
                    setTimeout("ff()","1100");


                }else {
                    layer.msg('委派失败', {icon: 2});
                    setTimeout("ff()","1100");
                }
            }
        })
    }


    /**
     * 获取数据
     */
    $.ajax({
        url:"getmaintian",
        type:"post",
        success:function (data){
        console.log(data)
            for (let i=0;i<data.length;i++){

                let sj=data[i]

                let newtr=$("<tr>")

                let td1=$("<td>")
                td1.html(sj.wxbh)

                let td2=$("<td>")
                td2.html(sj.bz)

                let td3=$("<td>")
                td3.html(sj.hhname)

                let td4=$("<td>")
                td4.html(sj.lxdh)

                let td5=$("<td>")
                td5.html(sj.sqsj)

                let td6=$("<td>")

                let but=$("<button>")
                but.attr("class","btn btn-info")
                but.attr("onclick",'wp('+sj.wxbh +','+sj.lxdh+')')

                let sp=$("<span>")
                sp.attr("class","glyphicon glyphicon-pencil")
                but.html(sp)

                td6.html(but)
                newtr.append(td1,td2,td3,td4,td5,td6)


                $("#tab").append(newtr)



            }
        }

    })
</script>
</body>
</html>